﻿Imports System.Collections.ObjectModel
Imports OMANE.Common.Model.Interfaces
Imports Actuariat
Imports PTIC_GestionBDD
Imports PTIC_Util

Public Class TablesMaintienINCINV_FraFactory
    Inherits TablesTravailFactory
    Implements Actuariat.ITablesMaintienINCINV_FraFactory

    Public Sub New(ByVal InfosTables As ReadOnlyCollection(Of IInfoTableReferentiel),
                   ByVal ListeTraitements As ListeTraitementsBase(Of String))
        MyBase.New(InfosTables, ListeTraitements)
        m_ListeTablesMaintienINCINV_Fra = New Dictionary(Of IInfoTableReferentiel, ITableMaintienINCINV_Fra)
    End Sub

    Private m_ListeTablesMaintienINCINV_Fra As IDictionary(Of IInfoTableReferentiel, ITableMaintienINCINV_Fra)
    Public ReadOnly Property Item(ByVal NomTable As String) As Actuariat.ITableMaintienINCINV_Fra Implements Actuariat.ITablesMaintienINCINV_FraFactory.Item
        Get
            Dim InfoTable As IInfoTableReferentiel = (From elt As IInfoTableReferentiel In InfosTables
                                                     Select elt
                                                     Where elt.NomTable = NomTable).AsEnumerable.FirstOrDefault

            If m_ListeTablesMaintienINCINV_Fra.ContainsKey(InfoTable) Then
                Return m_ListeTablesMaintienINCINV_Fra(InfoTable)
            Else
                Dim Trait As TableBDD_SAS = Traitements(InfoTable)
                Dim DtbleINCINV_Fra As DataTable = Trait.execute_DataTableSortie(False)
                Dim TableINCINV_Fra As ITableMaintienINCINV_Fra = New TableINCINV_FraFromDataTable(DtbleINCINV_Fra, InfoTable.NomTable)
                m_ListeTablesMaintienINCINV_Fra.Add(InfoTable, TableINCINV_Fra)
                Return TableINCINV_Fra
            End If
        End Get
    End Property
End Class
